package com.region.plugin;

/**
 * Proxy implementation interface class
 *
 * @author liujieyu
 * @date 2023/5/23 20:13
 * @desciption
 */
public interface Interceptor {

    /**
     * Execute the proceed() method predecessor method
     */
    default void doBefore() {
        // do before
    }

    /**
     * Execute the proceed() method post method
     */
    default void doAfter() {
        // do after
    }

    /**
     * Execute the method after the error in the proceed() method
     */
    default void doAfterThrowing(Throwable throwable) throws Throwable {
        // do after throwable
        throw throwable;
    }

    /**
     * Doing an interception and executing Proceed.proceed() method is to continue executing the proxied method
     *
     * @param proceed
     * @return
     */
    default Object proceed(ProceedPoint proceed) throws Throwable {
        return proceed.proceed();
    }

    /**
     * Interceptor weights
     *
     * @return
     */
    default int order() {
        return 0;
    }
}
